using LuckyLang.AST.Expression.ValueTyre;

namespace LuckyLang.AST.Statement;

public class IfStatement : Statement
{
    public IfBlock        If   { get; set; }
    public List<IfBlock>  Elif { get; set; }
    public BlockStatement Else { get; set; }

    public IfStatement(IfBlock ifBlock,List<IfBlock> elif,BlockStatement block)
    {
        Else = block;
        If   = ifBlock;
        Elif = elif;
    }
    public override void Run(ref VariateManager Manager)
    {
        bool isPass = false;
        If.Run(ref Manager,ref isPass);
        foreach (var ifBlock in Elif)
            ifBlock.Run(ref Manager,ref isPass);
        if (!isPass&&Else is not null)
            Else.Run(ref Manager);
    }
}